<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>企业管理系统</title>
<meta name="renderer" content="webkit"/>
  <meta name="viewport" content="width=device-width, initial-scale=1"/>
  <link rel="stylesheet" href="layui/css/layui.css" media="all"/>
    <script src="layui/layui.js"></script>
    <!-- jQuery -->
<script src="js/jquery.js"></script>
<!-- jQuery -->
<script src="../plugins/jquery/jquery.min.js"></script>
<script src="js/ajax.js"></script>
  <script>
    //依赖 element 模块，否则无法进行功能性操作
    layui.use('element', function(){
        var element = layui.element;
    });
    function close() {
		if(confirm("您确定要退出登录？")) {
			$.ajax({
				url:"Sp/outlogin",
				type:"post",
				success:function(){
				},
				error:function(){
				}
			})
			window.location.href="/";
		} else {}
	}
    function numzhengze(value) {
    	if(value=="")
       	   return "";
    	var priceReg = /(^[1-9]\d*(\.\d{1,2})?$)|(^0(\.\d{1,2})?$)/;
    	if (!priceReg.test(value)){

    		layer.msg("请输入正确价格:整数或者保留两位小数")
    	  return "";
    	}
 	   return value;
    }
    function zhzs(value) {
    	   value = value.replace(/[^\d]/g, '').replace(/^0{1,}/g, '');
    	   if (value != '')
    	      value = parseFloat(value);//.toFixed(3);//小数点
    	   else
    	      value = parseFloat(0);//.toFixed(3);
    	   return value;
    	}
</script>
  <link rel="stylesheet" href="/layui/a.css"  media="all"/>
  <link rel="stylesheet" href="/layui/b.css" media="all"/>
</head>
<body>
<div class="layui-layout layui-layout-admin">
<div style="background-image: url('/image/toubu2.jpg'); background-size:100% 100% ; background-attachment: fixed;" class="layui-header header header-demo">
  <div class="layui-main">
  <label class="layui-label" style="font-size: 30px;color: white;margin-top: 15px;position: absolute;font-family:华文行楷;">HD海德塑业</label>
    <label class="layui-label" style="position: absolute; left: 40%; margin-top: 10px;font-size: 25px;font-family:STSong;color:white">广西海德企业管理系统</label>
    <ul class="layui-nav">
	  <li class="layui-nav-item">
        <a href="javascript:;"> <i class="layui-icon layui-icon-print"></i><span id="printcount" class="layui-badge" style="margin-right: -10px;">0</span></a>
        <dl id="printstatus" class="layui-nav-child" style="left: auto; right: -22px; text-align: center;">
          <dd>
            <a id="layui-spm-event-aliyun">未打印货单<span class="layui-badge-dot" style="margin-top: -5px;"></span></a>
          </dd>
        </dl>
      </li>
	  <li class="layui-nav-item">
        <a href="javascript:;"> <i class="layui-icon layui-icon-notice"></i><span id="yjcount" class="layui-badge" style="margin-right: -10px;">0</span></a>
        <dl id="zyj" class="layui-nav-child" style="left: auto; right: -22px; text-align: center;">
          <dd>
            <a target="_blank" id="layui-spm-event-aliyun">发货货单逾期告警<span class="layui-badge-dot" style="margin-top: -5px;"></span></a>
          </dd>
        </dl>
      </li>
      <li class="layui-nav-item">
        <a id="quxianname" style="font-size: 18px;" href="javascript:;"><!--<span class="layui-badge-dot" style="left:0; right: auto; margin: -4px 0 0 5px;"></span>--> </a>
        <a id="username" style="font-size: 18px;" href="javascript:;"><!--<span class="layui-badge-dot" style="left:0; right: auto; margin: -4px 0 0 5px;"></span>--> </a>
      </li>
      <li class="layui-nav-item layui-hide-xs">
        <a href="javascript:close();" target="_blank" style="font-size: 18px;">退出登录</span></a>
      </li>
    </ul>
  </div>
</div>
  <div class="layui-side layui-bg-black">
    <div class="layui-side-scroll">
      
<ul class="layui-nav layui-nav-tree site-demo-nav">
  
  <li id="mate" class="layui-nav-item layui-nav-itemed">
    <a class="javascript:;" href="javascript:;">原料系统</a>
    <dl class="layui-nav-child">
      <dd class="layui-this">
        <a style="margin-left: 22px;" href="/addmate.html">原料制单</a>
      </dd>
    </dl>
    <dl class="layui-nav-child">
      <dd>
        <a style="margin-left: 22px;" href="/matecon.html">原料管理</a>
      </dd>
    </dl>
  </li>
  
  <li id="sell" class="layui-nav-item layui-nav-itemed">
    <a class="javascript:;" href="javascript:;">货单系统</a>
    <dl class="layui-nav-child">
      <dd class="">
        <a style="margin-left: 22px;" href="/addsell.html">货单制单</a>
      </dd>
    </dl>
    <dl class="layui-nav-child">
      <dd class="">
        <a style="margin-left: 22px;" href="/sellcon.html">货单管理</a>
      </dd>
    </dl>
    <dl id='fd' class="layui-nav-child">
      <dd class="">
        <a style="margin-left: 22px;" href="/sellcon2.html">废单管理</a>
      </dd>
    </dl>
  </li>
  <li id="stock" class="layui-nav-item">
    <a class="javascript:;" href="javascript:;">库单系统</a>
    <dl class="layui-nav-child">
      <dd class="">
        <a style="margin-left: 22px;" href="/stock.html">库单制单</a>
      </dd>
    </dl>
    <dl class="layui-nav-child">
      <dd class="">
        <a style="margin-left: 22px;" href="/stockGL.html">库单管理</a>
      </dd>
    </dl>
    <dl id="kcxh" class="layui-nav-child">
      <dd class="">
        <a style="margin-left: 22px;" href="/stockXH.html">库单型号</a>
      </dd>
    </dl>
  </li>
  <li id="pay" class="layui-nav-item">
    <a class="javascript:;" href="javascript:;">货款系统</a>
    <dl class="layui-nav-child">
      <dd class="layui-this">
        <a style="margin-left: 22px;" href="paycom.html">货款制单</a>
      </dd>
    </dl>
    <dl class="layui-nav-child">
      <dd class="">
        <a style="margin-left: 22px;" href="paycomGL.html">货款管理</a>
      </dd>
    </dl>
  </li>
  <li id="exin" class="layui-nav-item">
    <a class="javascript:;" href="javascript:;">资金系统</a>
    <dl class="layui-nav-child">
      <dd class="">
        <a style="margin-left: 22px;" href="income.html">
          收入制单
        </a>
      </dd>
    </dl>
    <dl class="layui-nav-child">
      <dd class="">
        <a style="margin-left: 22px;" href="incomeGL.html">
          收入管理
        </a>
      </dd>
    </dl>
    <dl class="layui-nav-child">
      <dd class="">
        <a style="margin-left: 22px;" href="expend.html">
          支出制单
        </a>
      </dd>
    </dl>
    <dl class="layui-nav-child">
      <dd class="">
        <a style="margin-left: 22px;" href="expendGL.html">
          支出管理
        </a>
      </dd>
    </dl>
  </li>
  <li id="tj" class="layui-nav-item">
    <a class="javascript:;" href="javascript:;">统计报表</a>
    <dl id="yl" class="layui-nav-child">
      <dd class="">
        <a style="margin-left: 22px;" href="yuanliaoTJ.html">
          原料统计
        </a>
      </dd>
    </dl>
    <dl id="hd" class="layui-nav-child">
      <dd class="">
        <a style="margin-left: 22px;" href="huodanTJ.html">
          货单统计
        </a>
      </dd>
    </dl>
    <dl id="sr" class="layui-nav-child">
      <dd class="">
        <a style="margin-left: 22px;" href="incomeTJ.html">
          收入统计
        </a>
      </dd>
    </dl>
    <dl id="zc" class="layui-nav-child">
      <dd class="">
        <a style="margin-left: 22px;" href="expendTJ.html">
          支出统计
        </a>
      </dd>
    </dl>
    <dl id="qk" class="layui-nav-child">
      <dd class="">
        <a style="margin-left: 22px;" href="qiankuanTJ.html">
          欠款统计
        </a>
      </dd>
    </dl>
    <dl id="kc" class="layui-nav-child">
      <dd class="">
        <a style="margin-left: 22px;" href="kucunTJ.html">
          库单统计
        </a>
      </dd>
    </dl>
  </li>
  <li class="layui-nav-item">
    <a class="javascript:;" href="javascript:;">客户信息</a>
    <dl id="addshopper" class="layui-nav-child">
      <dd>
       <a style="margin-left: 22px;" href="/shopper.html">
          添加客户
        </a>
      </dd>
    </dl>
    <dl id="shopper" class="layui-nav-child">
      <dd class="">
         <a style="margin-left: 22px;" href="/shopperGL.html">
          客户管理
        </a>
      </dd>
    </dl>
  </li>
  <li class="layui-nav-item">
    <a class="javascript:;" href="javascript:;">账号</a>
    <dl id="adduser" class="layui-nav-child">
      <dd>
       <a style="margin-left: 22px;" href="/user.html">
          添加账号
        </a>
      </dd>
    </dl>
    <dl id="user" class="layui-nav-child">
      <dd class="">
         <a style="margin-left: 22px;" href="/userGL.html">
          账号管理
        </a>
      </dd>
    </dl>
    <dl class="layui-nav-child">
      <dd class="">
        <a style="margin-left: 22px;" href="updatepawod.html">
          修改密码
        </a>
      </dd>
    </dl>
    <dl class="layui-nav-child">
      <dd class="">
        <a style="margin-left: 22px;" href="javascript:close();">
          注销
        </a>
      </dd>
    </dl>
  </li>
  
  <li class="layui-nav-item" style="height: 30px; text-align: center"></li>
</ul>

    </div>
  </div>
  <div class="layui-tab layui-tab-brief" lay-filter="demoTitle">
    <div class="layui-body layui-tab-content site-demo site-demo-body">
    
    
      <div class="layui-tab-item layui-show">
        <div class="layui-main">
          <div id="LAY_preview">
              
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
  <legend>原料制单</legend>
</fieldset>
 
<form class="layui-form" action="/Sp/addord" lay-filter="example" method="post">
	<input type="hidden" name="faf" value="add">
	<input type="hidden" name="id" value="1">
  <div class="layui-form-item">
    <label class="layui-form-label">名称</label>
    <div class="layui-input-block">
      <input type="text" name="name" lay-verify="required" lay-reqtext="请输入名称" placeholder="请输入名称" class="layui-input"/>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">类型</label>
    <div class="layui-input-block">
      <input type="text" name="type" lay-verify="required" lay-reqtext="请输入类型" placeholder="请输入类型" class="layui-input"/>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">型号</label>
    <div class="layui-input-block">
      <input type="text" name="modele" lay-verify="required" lay-reqtext="请输入型号" placeholder="请输入型号" class="layui-input"/>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">数量</label>
    <div class="layui-input-block">
      <input type="text" name="quantite" onblur="value=zhzs(this.value)" lay-verify="required" lay-reqtext="请输入数量" placeholder="请输入数量" class="layui-input"/>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">单位</label>
    <div class="layui-input-block">
      <select name="unite">
        <option value="吨" selected="selected">吨</option>
        <option value="包">包</option>
        <option value="米">米</option>
        <option value="卷">卷</option>
      </select>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">单价</label>
    <div class="layui-input-block">
      <input type="text" name="money" onblur="value=numzhengze(this.value)" lay-verify="required" lay-reqtext="是必填项" placeholder="请输入单价" class="layui-input"/>
    </div>
  </div>
  <div class="layui-form-item">
      <label class="layui-form-label">时间</label>
      <div class="layui-input-inline">
        <input type="text" name="time" id="date" lay-verify="required" lay-reqtext="请选择时间" placeholder="请选择时间" autocomplete="off" class="layui-input"/>
      </div>
    </div>
  <!-- <div id="saisieSelect" class="layui-form-item">
    <label class="layui-form-label">制单人</label>
    <div class="layui-input-block">
		<select id="select" name="saisie" lay-search>
		</select>
    </div>
  </div> -->
  <div class="layui-form-item">
    <label class="layui-form-label">制单人</label>
    <div class="layui-input-block">
      <input type="text" name="saisie" id="saisie" style="background-color: #DCDCDC;" disabled="disabled" class="layui-input"/>
    </div>
  </div>
  
  
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
  </div>
  </form>
  
  </div>
  </div>
  </div>
  </div>
  </div>
  <div class="layui-footer footer footer-demo">
  <div class="layui-main">
    <p>
      Build By 广西海德塑料有限责任公司
    </p>
  </div>
</div>
</div>
<div id="LAY_democodejs">
<script>
layui.use(['layer','form', 'layedit', 'laydate'], function(){
  var form = layui.form
  ,layer = layui.layer
  ,layedit = layui.layedit
  ,laydate = layui.laydate;
  var strcookie = document.cookie;//获取cookie字符串 
      var arrcookie = strcookie.split("; ");//分割 
      //遍历匹配 
      for ( var i = 0; i < arrcookie.length; i++) { 
	  console.log(arrcookie[i]); 
          var arr = arrcookie[i].split("="); 
          if (arr[0] == "username"){ 
		document.getElementById("saisie").value=arr[1].substring(arr[1].indexOf(":")+1);
  		document.getElementById("username").innerHTML=arr[1];
          } 
      } 
　　if(document.getElementById("username").innerHTML.indexOf("销售")!=-1){
		document.getElementById("mate").style.display="none"; 
		document.getElementById("pay").style.display="none"; 
		document.getElementById("exin").style.display="none"; 
		document.getElementById("tj").style.display="none"; 
		document.getElementById("user").style.display="none"; 
		document.getElementById("adduser").style.display="none"; 
		document.getElementById("shopper").style.display="none"; 
		document.getElementById("fd").style.display="none"; 
	}
	if(document.getElementById("username").innerHTML.indexOf("制单")!=-1){
		document.getElementById("exin").style.display="none"; 
		document.getElementById("yl").style.display="none"; 
		document.getElementById("sr").style.display="none";
		document.getElementById("zc").style.display="none";
		document.getElementById("hd").style.display="none";
		document.getElementById("user").style.display="none"; 
		document.getElementById("adduser").style.display="none"; 
		document.getElementById("shopper").style.display="none"; 
		document.getElementById("fd").style.display="none"; 
	}
	if(document.getElementById("username").innerHTML.indexOf("生产")!=-1){
		document.getElementById("mate").style.display="none"; 
		document.getElementById("sell").style.display="none"; 
		document.getElementById("pay").style.display="none"; 
		document.getElementById("exin").style.display="none"; 
		document.getElementById("tj").style.display="none"; 
		document.getElementById("user").style.display="none"; 
		document.getElementById("adduser").style.display="none"; 
		document.getElementById("shopper").style.display="none"; 
		document.getElementById("fd").style.display="none"; 
	}
	if(document.getElementById("username").innerHTML.indexOf("超")==-1){
		document.getElementById("kcxh").style.display="none"; 
	}
	$.ajax({
		url:"seleoddalltime",
		type:"post",
		success:function(a){
			console.log(a);
			document.getElementById("yjcount").innerHTML=a.count;
		for(var i= 0;i<a.count;i++){
			var demoListView = $('#zyj')
			var str="<dd lay-unselect> <a id='yj"+i+"' href='"+a.href[i]+"'>逾期告警<span class='layui-badge-dot' style='margin-top: -5px;'></span></a></dd>"
			
	          demoListView.append(str);
			document.getElementById('yj'+i).innerHTML=a.str[i];	
		}			
		},
		error:function(){
			console.log("逾期告警发生异常");
			
		}
	})
	$.ajax({
		url:"Sp/seleprintstatus",
		type:"post",
		success:function(a){
			console.log(a);
			document.getElementById("printcount").innerHTML=a.count;
		for(var i= 0;i<a.count;i++){
			var demoListView = $('#printstatus')
			var str="<dd lay-unselect> <a id='dyyj"+i+"' href='"+a.href[i]+"'>逾期告警<span class='layui-badge-dot' style='margin-top: -5px;'></span></a></dd>"
			
	          demoListView.append(str);
			document.getElementById('dyyj'+i).innerHTML=a.string[i];	
		}			
		},
		error:function(){
			console.log("打印告警发生异常");
			
		}
	})
  //日期
  laydate.render({
    elem: '#date',
    type: 'datetime'
  });
	//获取制单员select
	   $.ajax({
	 		url:"Sp/seleallzhidan",
	 		type:"post",
	 		dataType:"",
	 		success:function(btn){
	 	          var select = $("#select");//TypeID为HTML标签ID
	 		      	for (var j = 0; j < btn.count; j++) {
	 		      	  select.append("<option value='"+btn.data[j]+"'>"+btn.data[j]+"</option>");
	 		  		}
	 	          layui.form.render("select");
	 		},
	 		error:function(){
				
				layer.msg("发生异常");
	 		}
	 	})
	var url = location.search;  
	if (url.indexOf("?") != -1) {
	  var str = url.substr(1);      
	}
	if(url!=null&&url!="")
	$.ajax({
		url:"Sp/selematerialbyid",
		type:"post",
		data:{"id":str},
		dataType:"",
		success:function(a){
			//表单赋值
		    form.val('example', {
		      "id": a.id
		      ,"name": a.name
		      ,"type": a.type
		      ,"modele": a.modele
		      ,"quantite": a.quantite 
		      ,"unite": a.unite 
		      ,"money": a.money
			  ,"time": a.time
		      ,"saisie": a.saisie
		      ,"faf": "up"
		    });				
		},
		error:function(){
			if(str==null||str==""){
				
			}else
				layer.msg("发生异常");
			
		}
	})
	  //监听提交
	   form.on('submit(demo1)', function(data){
		   $.ajax({
				url:"Sp/addmate",
				type:"post",
				data:data.field,
				dataType:"",
				success:function(a){
					layer.msg(a);
					form.val('example', {
					      "id": ''
					      ,"name": ''
					      ,"type": ''
					      ,"modele": ''
					      ,"quantite": '' 
					      ,"unite": '' 
					      ,"money": ''
						  ,"time": ''
					      ,"faf": "add"
					    });	
				},
				error:function(){
					layer.msg("发生异常");
					
				}
			})
	    return false;
	  }); 
	
});
</script>
</div>
</body>
</html>